package com.base.study.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.study.R;
import com.base.study.bean.SubjectListBean;
import com.base.study.databinding.ActivityTestPaperTypeDetailsBinding;
import com.google.gson.Gson;

@Route(path = "/subject/test_typedetail")
public class TestPaperTypeDetailActivity extends CBaseBarMvpActivity {

    private ActivityTestPaperTypeDetailsBinding mBinding;

    @Autowired
    public String rows;

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_test_paper_type_details;
    }

    @Override
    protected void init() {
        super.init();
        mBinding = (ActivityTestPaperTypeDetailsBinding) mRootBinding;
        setBackNavigation();
        setBarTitle("试题详情");


    }

    @Override
    protected void start() {
        if (!TextUtils.isEmpty(rows)) {
            Gson gson = new Gson();
            SubjectListBean.Rows r = gson.fromJson(rows, SubjectListBean.Rows.class);
            mBinding.tvTestType.setText(r.getQuestionsType());
            mBinding.tvTestName.setText(r.getItemName());
            mBinding.linJudgementQuestion.setVisibility(View.VISIBLE);
            mBinding.tvQuestionAnswersOne.setText(r.getAnswerOne());
            mBinding.tvQuestionAnswersTwo.setText(r.getAnswerTwo());
            mBinding.tvQuestionAnswersThree.setText(r.getAnswerThree());
            mBinding.tvQuestionAnswersFour.setText(r.getAnswerFour());
            mBinding.tvQuestionAnswersFive.setText(r.getAnswerFive());
            mBinding.tvQuestionAnswersSix.setText(r.getAnswerSix());
            if (!TextUtils.isEmpty(r.getAnswerOne())) {
                setViewIsGone(View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE, View.GONE);
            }
            if (!TextUtils.isEmpty(r.getAnswerTwo())) {
                setViewIsGone(View.VISIBLE, View.VISIBLE, View.GONE, View.GONE, View.GONE, View.GONE);
            }
            if (!TextUtils.isEmpty(r.getAnswerThree())) {
                setViewIsGone(View.VISIBLE, View.VISIBLE, View.VISIBLE, View.GONE, View.GONE, View.GONE);
            }
            if (!TextUtils.isEmpty(r.getAnswerFour())) {
                setViewIsGone(View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE, View.GONE, View.GONE);
            }
            if (!TextUtils.isEmpty(r.getAnswerFive())) {
                setViewIsGone(View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE, View.GONE);
            }
            if (!TextUtils.isEmpty(r.getAnswerSix())) {
                setViewIsGone(View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE, View.VISIBLE);
            }
            if ("判断题".equals(r.getQuestionsType())) {
                mBinding.tvReferenceAnswer.setText(r.getJudgePickFruits());
                if (!TextUtils.isEmpty(r.getJudgeanswerInstructions())) {
                    mBinding.tvAnswerDes.setText(r.getJudgeanswerInstructions());
                }

            } else if ("单选题".equals(r.getQuestionsType())) {
                mBinding.tvReferenceAnswer.setText(r.getPickFruits());
                if (!TextUtils.isEmpty(r.getAnswerInstructions())) {
                    mBinding.tvAnswerDes.setText(r.getAnswerInstructions());
                }
            } else if ("多选题".equals(r.getQuestionsType())) {
                mBinding.tvReferenceAnswer.setText(r.getMultiSelectFruits());
                if (!TextUtils.isEmpty(r.getMultiSelectInstructions())) {
                    mBinding.tvAnswerDes.setText(r.getMultiSelectInstructions());
                }
            }


        }

    }


    private void setViewIsGone(int one, int two, int three, int four, int five, int six) {
        mBinding.tvQuestionAnswersOne.setVisibility(one);
        mBinding.tvQuestionAnswersTwo.setVisibility(two);
        mBinding.tvQuestionAnswersThree.setVisibility(three);
        mBinding.tvQuestionAnswersFour.setVisibility(four);
        mBinding.tvQuestionAnswersFive.setVisibility(five);
        mBinding.tvQuestionAnswersSix.setVisibility(six);
    }
}
